home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / MISC / TSTHFLT2 / CHECK.PAS < prev    next >
Pascal/Delphi Source File  |  1996-12-01  |  10KB  |  279 lines

  1. {(s0p16h0s0b4099T}
  2. Program Con_filt;
  3.  
  4. {
  5.   This program is a PG utillity for TSTHOST 1.41 and higher.
  6.   This program access TSTHOST for information about the status of the
  7.   program and the tasks. Extended data request will be done trought the
  8.   internally IQR service vector, normally 101, 65Hex. This vector
  9.   may be redefined with the command TSTHOST/V, that accept in input a
  10.   DECIMAL value. This program is tested with TSTHOST 1.43b.
  11.   Written by Reg, PE1PKD, BLOKKER in HOLLAND.
  12.   Packet address : PE1PKD @ PI8WFL.#NH1.NLD.EU
  13. }
  14.      
  15. Uses Dos;
  16.      
  17. Type
  18.   InfoRec = Record
  19.      (* This record is translated from the C layout from the manual into
  20.         Turbo Pascal layout. The record names are exactly the same as
  21.         described in the manual.*)
  22.      (* THIS VALUE ARE GLOBALS, NOT CHANNEL DEPANDANT.*)
  23.      (*=============================================== *)
  24.      THVH           : Byte;                  (*TstHost version, high value*)
  25.      THVL           : Byte;                  (*TstHost version, low value*)
  26.      MAXCHANNEL     : Integer;               (*Number of channel available i tsthost*)
  27.      DRVTYPE        : Byte;                  (*Driver type, 1 real host, 0 tfpc, 2 drsi*)
  28.      PORT           : Byte;                  (*If real host, com port*)
  29.      BAUDRATE       : Word;                  (*If real host, baudrate*)
  30.      INTNO          : Integer;               (*If tfpcx/r, irq vector used by driver*)
  31.      TstHostCall    : Array[0..9] of Char;   (*Callsign of the sistem, with ssid*)
  32.      UListEnable    : Byte;                  (*If not 0, unproto list is  active*)
  33.      Wpath          : Array[0..80] of Char;  (*tsthost WorkDir*)
  34.      Upath          : Array[0..100] of Char; (*tsthost UserDir. If more than one path*)
  35.                                              (*is defined, the multiple path are*)
  36.                                              (*separated by a space.*)
  37.      HomeBbs        : Array[0..9] of Char;   (*HomeBbs Callsign*)
  38.      HomeAlias      : Array[0..9] of Char;   (*homebbs alias call, null if undefined*)
  39.  
  40.      (* THIS FIELDS ARE CHANNEL DEPANDANT*)
  41.      (*====================================================*)
  42.      Chstatus       : Integer;               (*0 channel is disconnected*)
  43.                                              (*1 standard connection, I have connect*)
  44.                                              (*  another OM*)
  45.                                              (*2 PMS connection, a remote user is*)
  46.                                              (*  connected on my pms*)
  47.                                              (*3 PMS connection, HomeBbs have connect*)
  48.                                              (*  my pms to do forward.*)
  49.                                              (*4 PMS connection, my pms have connect*)
  50.                                              (*  HomeBbs to do forward*)
  51.                                              (*5 UNPROTO connection, i have connect*)
  52.                                              (*  HomeBbs to request unproto mail.*)
  53.      SuppCall       : Array[0..9] of Char;   (*If not null, extra callsign for the*)
  54.                                              (*channel (command AX PORT)*)
  55.      UserCall       : Array[0..9] of Char;   (*call of the connected station, with ssid*)
  56.  
  57.      (* THIS FIELDS ARE VALID ONLY FOR USER THAT HAVE CONNECT*)
  58.      (* MY PMS, chstatus=2 o 3*)
  59.      (*=====================================================*)
  60.      UIname         : Array[0..12] of Char;  (*User name*)
  61.      UILastConnTime : LongInt;               (*in sec dal 1970, last connection date*)
  62.      UILastMsgList  : LongInt;               (*in sec, last messaged listed date*)
  63.      UINbrConn      : LongInt;               (*number of connection for this user*)
  64.      UIThisConnTime : LongInt;               (*in second, this date at connection*)
  65.      SysFlag        : Word;                  (*actual SYS flag for the user*)
  66.    End;
  67.    ChannelList      = Array[0..8] of InfoRec;
  68.  
  69. Var
  70.   Reg              : Registers;
  71.   Point            : ^InfoRec ;    {typed pointer}
  72.   ChannelData      : ChannelList;  {all record data off the channels}
  73.   TsthostPath      : String;       {path where TSHOST.EXE is located}
  74.   TsthostIRQVector : Byte;         {IRQ vector to get the info}
  75.                                    {WARNING : This is NOT the IRQ vector for
  76.                                     communication to e.g. TFPCX(286) driver!}
  77.  
  78.  
  79. Function GetTsthostPath : String;
  80.  
  81. { This function is returning the path where tsthost.exe is located. }
  82.  
  83. Var
  84.   PathName     : PathStr;
  85.   DirName      : Dirstr;
  86.   ProgName     : NameStr;
  87.   ExtName      : ExtStr;
  88.   DirInfo      : SearchRec;
  89.   PGPos        : Byte;
  90.  
  91. Begin
  92.   PathName := Fexpand(ParamStr(0));
  93.   FSplit(PathName,DirName,ProgName,ExtName);
  94.   PGPos := Pos('PG',DirName);
  95.   If PGPos = 0 then GetTsthostPath := 'C:\TSTHOST\'
  96.     else GetTsthostPath := Copy(DirName,1,PGPos-1);
  97. End;
  98.  
  99.  
  100. Procedure GetInfo(TsthostIRQ : Byte;  ALByte : Byte);
  101.  
  102. { This procedure gets the information from the memory location.
  103.   WARNING : On page 8 of the TSHOST 1.43 manual is mensioned that
  104.   register AH is set to the specified channel to investigate. This must
  105.   be register AL! }
  106.  
  107. Begin
  108.   With Reg do
  109.   Begin
  110.     AL := ALByte;
  111.     AH := 0;
  112.     Intr(TsthostIRQ, Reg);
  113.     If AH <> 0 Then {When returning AH must be 0}
  114.     Begin
  115.       Writeln('Can not connect to TSTHOST.');
  116.       Halt(0);
  117.     End;
  118.     Point := Ptr(ES,BX);
  119. {
  120.     Writeln('AL ',AL);
  121.     Writeln('AH ',AH);
  122. }
  123.   End;
  124. End;
  125.  
  126.  
  127. Procedure WriteInfo;
  128.  
  129. { Temporally procedure to display the data }
  130.  
  131. Begin
  132.   With Point^ do
  133.   Begin
  134.     Writeln ('THVH>>>',THVH,'<<<');
  135.     Writeln ('THVL>>>',THVL,'<<<');
  136.     Writeln ('MAXCHANNEL    >>>',MAXCHANNEL,'<<<');
  137.     Writeln ('DRVTYPE       >>>',DRVTYPE,'<<<');
  138.     Writeln ('PORT          >>>',PORT,'<<<');
  139.     Writeln ('BAUDRATE      >>>',BAUDRATE,'<<<');
  140.     Writeln ('INTNO         >>>',INTNO,'<<<');
  141.     Writeln ('TstHostCall   >>>',TstHostCall,'<<<');
  142.     Writeln ('UListEnable   >>>',UListEnable,'<<<');
  143.     Writeln ('Wpath         >>>',Wpath,'<<<');
  144.     Writeln ('Upath         >>>',Upath,'<<<');
  145.     Writeln ('HomeBbs       >>>',HomeBbs,'<<<');
  146.     Writeln ('HomeAlias     >>>',HomeAlias,'<<<');
  147.     Writeln ('Chstatus      >>>',chstatus,'<<<');
  148.     Writeln ('SuppCall      >>>',SuppCall,'<<<');
  149.     Writeln ('UserCall      >>>',UserCall,'<<<');
  150.     Writeln ('UIname        >>>',UIname,'<<<');
  151.     Writeln ('UILastConnTime>>>',UILastConnTime,'<<<');
  152.     Writeln ('UILastMsgList >>>',UILastMsgList,'<<<');
  153.     Writeln ('UINbrConn     >>>',UINbrConn,'<<<');
  154.     Writeln ('UIThisConnTime>>>',UIThisConnTime,'<<<');
  155.     Writeln ('SysFlag       >>>',SysFlag,'<<<');
  156.   End;
  157. End;
  158.  
  159.  
  160. Function ReadTsthostInterruptVector : Byte;
  161.  
  162. { Read the IRQ vector from file TSTHOST.IRQ. This file only exist
  163.   when TSTHOST is started. This procedure checks or file exist and
  164.   so if TSTHOST is started.}
  165.  
  166. Var
  167.   IRQString,
  168.   Line,
  169.   TstHostIRQName : String;
  170.   TsthostIRQRead : Text;
  171.   DirInfo        : SearchRec;
  172.   IRQNumber,
  173.   Code           : Integer;
  174.   IRQPos         : Byte;
  175.  
  176. Begin
  177.   (* First check or this program is called under tsthost operation! *)
  178.   TsthostIRQName := GettsthostPath + 'TSTHOST.IRQ';
  179.  
  180.   FindFirst(TsthostIRQName,AnyFile,DirInfo);
  181.   If DosError > 0 then
  182.   Begin
  183.     Writeln('This programm requires TSTHOST.');
  184.     Halt(0);
  185.   End;
  186.  
  187.   Assign(TsthostIRQRead, TsthostIRQName);
  188.   {$I-}
  189.   Reset(TsthostIRQRead);
  190.   {SI+}
  191.   If IOResult <> 0 then
  192.   Begin
  193.     Writeln('Error reading file :',TsthostIRQName);
  194.     Halt(0);
  195.   End;
  196.  
  197.   Repeat
  198.     Readln(TsthostIRQRead,Line);
  199.     IRQPos := Pos('=',Line);
  200.     IRQString := Copy(Line,IRQPos+1,3);
  201.     Val(IRQString,IRQNumber,Code);
  202.     If (IRQPos = 0) or (Code <> 0) Then
  203.     Begin
  204.       Writeln('Error reading file :',TsthostIRQName);
  205.       Halt(0);
  206.     End;
  207.   Until Eof(TsthostIRQRead);
  208.  
  209.   Close(TsthostIRQRead);
  210.   ReadTsthostInterruptVector := IRQNumber;
  211. End;
  212.  
  213.  
  214. Procedure ScanChannels;
  215.  
  216. { Scans all channels and get the data }
  217.  
  218. Var
  219.   Channel : Byte;
  220.  
  221. Begin
  222.   GetInfo(TsthostIRQVector,0); {First scan the MONITOR channel}
  223.   ChannelData[0] := Point^; {Write data from memory in record}
  224.   For Channel := 1 to ChannelData[0].MaxChannel do { Scan the channels 1 to max.}
  225.   Begin
  226.     GetInfo(TsthostIRQVector,Channel);
  227.     ChannelData[Channel] := Point^;
  228. {    WriteInfo; }
  229.   End;
  230. End;
  231.  
  232.  
  233. Procedure DisplayStatus;
  234.  
  235. Var
  236.   Channel   : Byte;
  237.  
  238. Begin
  239.   For Channel := 1 to ChannelData[0].MaxChannel do { Scan the channels 1 to max.}
  240.   Begin
  241.     With ChannelData[Channel] do
  242.     Begin
  243.       Writeln('***Ch>>>',Channel,'<<<');
  244.       Writeln ('THVH>>>',THVH,'<<<');
  245.       Writeln ('THVL>>>',THVL,'<<<');
  246.       Writeln ('MAXCHANNEL    >>>',MAXCHANNEL,'<<<');
  247.       Writeln ('DRVTYPE       >>>',DRVTYPE,'<<<');
  248.       Writeln ('PORT          >>>',PORT,'<<<');
  249.       Writeln ('BAUDRATE      >>>',BAUDRATE,'<<<');
  250.       Writeln ('INTNO         >>>',INTNO,'<<<');
  251.       Writeln ('TstHostCall   >>>',TstHostCall,'<<<');
  252.       Writeln ('UListEnable   >>>',UListEnable,'<<<');
  253.       Writeln ('Wpath         >>>',Wpath,'<<<');
  254.       Writeln ('Upath         >>>',Upath,'<<<');
  255.       Writeln ('HomeBbs       >>>',HomeBbs,'<<<');
  256.       Writeln ('HomeAlias     >>>',HomeAlias,'<<<');
  257.       Writeln ('Chstatus      >>>',chstatus,'<<<');
  258.       Writeln ('SuppCall      >>>',SuppCall,'<<<');
  259.       Writeln ('UserCall      >>>',UserCall,'<<<');
  260.       Writeln ('UIname        >>>',UIname,'<<<');
  261.       Writeln ('UILastConnTime>>>',UILastConnTime,'<<<');
  262.       Writeln ('UILastMsgList >>>',UILastMsgList,'<<<');
  263.       Writeln ('UINbrConn     >>>',UINbrConn,'<<<');
  264.       Writeln ('UIThisConnTime>>>',UIThisConnTime,'<<<');
  265.       Writeln ('SysFlag       >>>',SysFlag,'<<<');
  266.     End;
  267.   End;
  268. End;
  269.  
  270.  
  271. Begin { main }
  272.   TsthostIRQVector := ReadTsthostInterruptVector;
  273.   ScanChannels;
  274.   DisplayStatus;
  275. End.
  276.  
  277.  
  278.  
  279.